from enum import unique
from uuid import uuid4
from app import db
from DataManager.models import Data


class Device(db.Model):
    __tablename__ = "devices"
    __table_args__ = {"schema": "AeroSentinel"}
    uuid = db.Column(db.String(36), primary_key=True, default=lambda: str(uuid4()))
    user_id = db.Column(db.String(36), db.ForeignKey("AeroSentinel.users.uuid"))

    name = db.Column(db.String(255), nullable=False, unique=True)
    secret = db.Column(db.String(255), nullable=False)
    location = db.Column(db.String(255))

    data = db.relationship(Data, backref="device", lazy=True)
